/**
 *	6.void written_amount(unsigned int amount,char *buffer);
 *	它把amount表示的值转化为单词形式，并存储于buffer中，这个函数可以在一个打印支票的程序中使用。例如，
 *	如果amount的值是16312,那么buffer中存储的字符串应该是：SIXTEEN THOUSAND THREE HUNDRED TWELVE
 *
 *	调用程序应该保证buffer缓冲区的空间足够大。
 *
 *	有些值可以用两种不同的方法进行打印。例如，1200可以是ONE THOUSAND TWO HUNDRED或TWELVE HUNDRED。
 *	你可以选择一种你喜欢的形式。
**/
#include <stdio.h>
#include <string.h>

#define LONG 1000

const char *unit[10] = {
	"zero", "one", "two", "three", "four",
	"five", "six", "seven", "eight", "nine" 
	};
const char *ten[10] = {
	"ten", "eleven", "twelve", "thirteen", "fourteen",
	"fifteen", "sixteen", "seventeen", "eighteen", "nineteen"
	};
const char *decade[10] = {
	" ", " ", "twenty", "thirty", "forty",
	"fifty", "sixty", "seventy", "eighty", "ninety"
	};

void written_amount(unsigned long int amount, char *buf);

int main()
{
	unsigned long int amount;
	char buffer[LONG] = "";
	scanf("%lu", &amount);
	written_amount(amount, buffer);
 	printf("%s\n", buffer);
	return 0;
}

void written_amount(unsigned long int amount, char *buffer)
{
	unsigned long int n = 100000000;
	if(amount / n)
	{
		int temp = amount / n;
		amount %= n;
		written_amount(temp, buffer);
		strcat(buffer, "billion");
	}
	
	n = 100000;
	if(amount / n)
	{
		int temp = amount / n;
		amount %= n;
		written_amount(temp, buffer);
		strcat(buffer, "million");
	} 

	n = 100;
	if(amount / n)
	{
		int temp = amount / n;
		amount %= n;
		written_amount(temp, buffer);
		strcat(buffer, "hundred");
	}
	
	n = 10;
	if(amount / n)
	{
		int temp = amount / n;
		amount %= n;
		if(temp == 1)
			strcat(buffer, ten[amount]);
		else
		{
			strcat(buffer, decade[temp]);
			if(amount != 0)
				strcat(buffer, unit[amount]);
		}		
	}
	else
		strcat(buffer, unit[amount]);
}

